package com.ruoyi.pangolin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pangolin.domain.SysPangolinIndustry;
import com.ruoyi.pangolin.service.ISysPangolinIndustryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行业类型Controller
 * 
 * @author wholve
 * @date 2023-01-22
 */
@RestController
@RequestMapping("/pangolin/industry")
public class SysPangolinIndustryController extends BaseController
{
    @Autowired
    private ISysPangolinIndustryService sysPangolinIndustryService;

    /**
     * 查询行业类型列表
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPangolinIndustry sysPangolinIndustry)
    {
        startPage();
        List<SysPangolinIndustry> list = sysPangolinIndustryService.selectSysPangolinIndustryList(sysPangolinIndustry);
        return getDataTable(list);
    }

    /**
     * 导出行业类型列表
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:export')")
    @Log(title = "行业类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPangolinIndustry sysPangolinIndustry)
    {
        List<SysPangolinIndustry> list = sysPangolinIndustryService.selectSysPangolinIndustryList(sysPangolinIndustry);
        ExcelUtil<SysPangolinIndustry> util = new ExcelUtil<SysPangolinIndustry>(SysPangolinIndustry.class);
        util.exportExcel(response, list, "行业类型数据");
    }

    /**
     * 获取行业类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysPangolinIndustryService.selectSysPangolinIndustryById(id));
    }

    /**
     * 新增行业类型
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:add')")
    @Log(title = "行业类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPangolinIndustry sysPangolinIndustry)
    {
        return toAjax(sysPangolinIndustryService.insertSysPangolinIndustry(sysPangolinIndustry));
    }

    /**
     * 修改行业类型
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:edit')")
    @Log(title = "行业类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPangolinIndustry sysPangolinIndustry)
    {
        return toAjax(sysPangolinIndustryService.updateSysPangolinIndustry(sysPangolinIndustry));
    }

    /**
     * 删除行业类型
     */
    @PreAuthorize("@ss.hasPermi('pangolin:industry:remove')")
    @Log(title = "行业类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysPangolinIndustryService.deleteSysPangolinIndustryByIds(ids));
    }
}
